package com.aiti.lulian.controller;

import com.aiti.base.core.utils.message.Message;
import com.aiti.lulian.annotates.LoginUser;
import com.aiti.lulian.bo.LoginUserInfo;
import com.aiti.lulian.dto.industry.*;
import com.aiti.lulian.service.CardGovFeaturedIndustryService;
import com.aiti.lulian.service.CardGovIndustrySupportContentService;
import com.aiti.lulian.service.CardGovIndustrySupportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @description: IndustryController
 * @auth fcb
 * @date 2025-03-04 15:06
 **/
@RestController
@RequestMapping("/industry")
@Api(tags = "特色产业")
public class IndustryController {

    @Autowired
    private CardGovFeaturedIndustryService cardGovFeaturedIndustryService;
    @Autowired
    private CardGovIndustrySupportService cardGovIndustrySupportService;
    @Autowired
    private CardGovIndustrySupportContentService supportContentService;

    @PostMapping("/add")
    @ApiOperation(value = "新增特色产业")
    public Message addIndustry(@Validated @RequestBody FeaturedIndustryParamDto paramDto, @LoginUser LoginUserInfo userInfo) {
        cardGovFeaturedIndustryService.addFeaturedIndustry(paramDto, userInfo);
        return Message.success();
    }

    @PostMapping("/update")
    @ApiOperation(value = "修改特色产业")
    public Message updateIndustry(@RequestBody FeaturedIndustryParamDto paramDto, @LoginUser LoginUserInfo userInfo) {
        cardGovFeaturedIndustryService.updateFeaturedIndustry(paramDto, userInfo);
        return Message.success();
    }

    @GetMapping("/featureList")
    @ApiOperation(value = "特色产业列表")
    public Message getFeaturedIndustryList() {
        return Message.success(cardGovFeaturedIndustryService.getFeaturedIndustryList());
    }

    @PostMapping("/featureListPage")
    @ApiOperation(value = "特色产业列表，分页查询")
    public Message getFeaturedIndustryListPage(@RequestBody FeaturedIndustryQueryDto queryDto) {
        return Message.success(cardGovFeaturedIndustryService.queryFeaturedIndustryListPage(queryDto));
    }

    @PostMapping("/delete")
    @ApiOperation(value = "删除特色产业")
    public Message deleteByIdList(@RequestBody List<String> baseIds) {
        cardGovFeaturedIndustryService.deleteFeaturedIndustry(baseIds);
        return Message.success();
    }

    @GetMapping("/detail")
    @ApiOperation(value = "特色产业详情")
    public Message getFeaturedIndustryById(@RequestParam(value = "baseId") String baseId) {
        return Message.success(cardGovFeaturedIndustryService.getFeaturedIndustryById(baseId));
    }

    //-------------------产业支持-----------------------------
    @PostMapping("/support/add")
    @ApiOperation(value = "新增产业支持")
    public Message addSupport(@RequestBody IndustrySupportParamDto paramDto, @LoginUser LoginUserInfo userInfo) {
        cardGovIndustrySupportService.addIndustrySupport(paramDto, userInfo);
        return Message.success();
    }

    @PostMapping("/support/update")
    @ApiOperation(value = "修改产业支持")
    public Message updateIndustrySupport(@RequestBody IndustrySupportParamDto paramDto, @LoginUser LoginUserInfo userInfo) {
        cardGovIndustrySupportService.updateIndustrySupport(paramDto, userInfo);
        return Message.success();
    }

    @GetMapping("/support/featureList")
    @ApiOperation(value = "产业支持功能列表")
    public Message getIndustrySupportList(@Param(value = "industryId")String industryId) {
        return Message.success(cardGovIndustrySupportService.getIndustrySupportList(industryId));
    }

    @PostMapping("/support/delete")
    @ApiOperation(value = "删除特色产业")
    public Message deleteSupportByIdList(@RequestBody List<String> baseIds) {
        cardGovIndustrySupportService.deleteIndustrySupport(baseIds);
        return Message.success();
    }

    @GetMapping("/support/detail")
    @ApiOperation(value = "特色产业功能详情")
    public Message getIndustrySupportById(@RequestParam(value = "baseId") String baseId) {
        return Message.success(cardGovIndustrySupportService.getIndustrySupportById(baseId));
    }

    // -----------------------产业支持内容---------------------------------
    @PostMapping("/support/content/add")
    @ApiOperation(value = "新增产业支持内容")
    public Message addIndustrySupportContent(@Validated @RequestBody SupportContentParamDto paramDto, @LoginUser LoginUserInfo userInfo) {
        supportContentService.addIndustrySupportContent(paramDto, userInfo);
        return Message.success();
    }

    @PostMapping("/support/content/update")
    @ApiOperation(value = "修改产业支持内容")
    public Message updateIndustrySupportContent(@RequestBody SupportContentParamDto paramDto, @LoginUser LoginUserInfo userInfo) {
        supportContentService.updateIndustrySupportContent(paramDto, userInfo);
        return Message.success();
    }

    @PostMapping("/support/content/list")
    @ApiOperation(value = "产业支持内容列表")
    public Message queryIndustrySupportContentList(@RequestBody SupportContentQueryDto queryDto) {
        return Message.success(supportContentService.queryIndustrySupportContentList(queryDto));
    }

    @PostMapping("/support/content/delete")
    @ApiOperation(value = "删除产业支持内容")
    public Message deleteIndustrySupportContent(@RequestBody List<String> baseIds) {
        supportContentService.deleteIndustrySupportContent(baseIds);
        return Message.success();
    }

    @GetMapping("/support/content/detail")
    @ApiOperation(value = "产业支持内容详情")
    public Message getIndustrySupportContentById(@RequestParam(value = "baseId") String baseId) {
        return Message.success(supportContentService.getIndustrySupportContentById(baseId));
    }

}
